<template>
  <div>
    <div class='service-column'> 
      <div class='title'>
        <div>
        <span class='iconfont iconweibiaoti-_huabanfuben'></span>
        <span>航协认证</span>
        </div>
         <div>
        <span class='iconfont iconbaozheng'></span>
        <span>出行保证</span>
        </div>
         <div>
        <span class='iconfont icondianhua'></span>
        <span>全天在线</span>
        </div>
      </div>
      <div class='tel'>
        <span>免费客服电话: 400635678</span>
      </div>
    </div> 
    <div class='inquire'>
      <div class='title'>
        历史查询
      </div>
      <div class='airpost'  @click="jumpAir(item)" v-for="(item,index) in historyList" :key="index">
        <div>
          <span>{{item.departCity}}-{{item.destCity}}</span>
          <span>{{item.departDate}}</span>
        </div>
        <div>
          <span>选择</span>
        </div>
      </div>
    </div>  
  </div>
</template>

<script>
export default {
  // 如果将获取store数据的流程放到data里面 那么就会造成页面渲染的时候会获取不到数据
  // 实例一渲染 data 就已经存在了 但是vuex里面的数据还是空的 等他到拿到数据的时候再给data的时候
  // data是不会有任何变化的 因为data没有监听数据变化的属性 数据的变更跟它没有联系
  // data() {
  //   return {
  //     // 获取store数据
  //     historyList: this.$store.state.history.list
  //   }
  // },
  // 我们可以使用watch监听数据的变化
  computed: {
    historyList() {
      return this.$store.state.history.list
    }
  },
  methods: {
    // 用户点击当前历史记录 携带数据重新搜索
    jumpAir(item) {
      // console.log(item)
      this.$router.push({
        path: '/air/flights',
        query: item
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.service-column {
  display: flex;
  flex-direction: column;
  border: 1px solid #dddddd;
  // align-items: baseline;
  justify-content: space-between;
  .title {
    padding: 15px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    div {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: center;
      span {
        font-size: 12px;
      }
      .iconfont {
        font-size: 40px;
        color: #409eff;
      }
      .iconbaozheng {
        color: #008000;
      }
    }
  }
  .tel {
    padding: 8px 0;
    font-size: 14px;
    background-color: #f6f6f6;
  }
}
.inquire {
  margin-top: 10px;
  border: 1px solid #eeeeee;
  .title {
    padding: 10px 0;
    margin: 0 5px;
    border-bottom: 1px solid #eeeeee;
  }
  .airpost {
    display: flex;
    justify-content: center;
    margin: 0 5px;
    align-items: center;
    padding: 10px 0;
    cursor: pointer;
    div {
      flex: 1;
    }
    div:nth-child(1) {
      span {
        display: block;
        font-size: 12px;
        color: #7f7eb5;
      }
      span:nth-child(1) {
        font-size: 14px;
        color: #000000;
      }
    }
    div:nth-child(2) {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      span {
        color: #ffffff;
        padding: 3px 8px;
        font-size: 12px;
        background-color: #ffa500;
        border-radius: 5px;
      }
    }
  }
}
</style>